package com.botarena.client;

import com.botarena.client.account.AccountEditor;
import com.botarena.client.battle.BattleViewer;
import com.botarena.client.contest.ContestViewer;
import com.botarena.shared.UserInfo;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.VerticalPanel;

/**
 * GUI dla Home Page
 * 
 * @author wirenth
 * 
 */
public class HomeViewer {

	public static Panel createHomePage(UserInfo userInfo, RightMenu rightMenu) {

		Panel panel = new VerticalPanel();
		panel.setStyleName("contentMain");
		
		Label title = new Label("Welcome to Bot Arena platform!");
		title.setStyleName("title");
		panel.add(title);
		
		HTML greeting = new HTML("Bot Arena is a place to test your programming skills. <a href=\"/#about\">Learn more...</a>");
		greeting.setStyleName("aboutParagraphs");
		panel.add(greeting);

		if (userInfo.isLoggedIn() && !userInfo.hasAccount()) {
			Label comment = new Label("Please create a new account:");
			comment.setStyleName("title5");
			panel.add(comment);
			panel.add(AccountEditor.createRegistrationForm(userInfo));
		} else if (rightMenu.getSelectedContest() == null) {
			panel.add(new Label("No contest selected"));
		} else {
			
			createHome(panel, rightMenu);
			
			//panel.add(new Label("All systems ready!"));
		}

		return panel;
	}

	private static void createHome(Panel panel, RightMenu rightMenu) {
		
		//Panel bottom = new HorizontalPanel();
		
		panel.add(ContestViewer.createContestInfoPanel(rightMenu));
		panel.add(ContestViewer.createTopNRank(rightMenu));
		panel.add(BattleViewer.createLastBattlesPanel(rightMenu));
		
		
	}

}
